'use strict';

/**
 * 门禁逻辑控制器
 */
const util = require('util');
const Code = require('../common/error_code');
const Cons = require('../common/constants');
const huaqiangClient = require('../utils/huaqiang_client');
const boxiniClient = require('../utils/boxini_client');
const logger = require('../utils/logger');


/**
 * type HUAQIANG/BOXINI
 * ip guard door ip
 * port port
 * no open channel:time
 */
function openDoor(type, ip, port, no) {
    if (Cons.SW_TYPE_HUAQIANG == type) {
        huaqiangClient.openDoor(ip, port, no);
    } else if (Cons.SW_TYPE_BOXINI == type) {
        boxiniClient.openDoor(ip, port, no);
    } else {
        logger.error('error guard door type ', type);
    } 
}

exports.openDoor = openDoor;

